home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 626-650 / 634 / apig / apig33.lzh / e6_requesters.rexx < prev    next >
OS/2 REXX Batch file  |  1992-01-26  |  5KB  |  157 lines

  1. /*  Example Using Requesters  */
  2.  
  3. /*  */
  4. x = addlib("apig.library",0,-30,0)
  5.  
  6. portname = "examplereq6_port"
  7. p = openport(portname)
  8. call set_apig_globals()
  9. scrtitle = "Hey Buddy, Yea You,  This is Your New Screen  !"
  10. wintitle = "This is your title"
  11. winidcmp = CLOSEWINDOW+MENUPICK
  12. winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO+ACTIVATE
  13.  
  14. scr = openscreen(0,0,640,400,3,4,5,LACE+HIRES,CUSTOMSCREEN,scrtitle)
  15.  
  16. /* open window */
  17. call setrgb4(scr,0,3,3,3)
  18. call setrgb4(scr,1,0,0,0)
  19. call setrgb4(scr,2,0,0,7)
  20. call setrgb4(scr,3,15,15,0)
  21. call setrgb4(scr,4,15,5,1)
  22. call setrgb4(scr,5,0,8,15)
  23. call setrgb4(scr,6,0,15,0)
  24. call setrgb4(scr,7,6,5,4)
  25.  
  26. w1  = openwindow(portname,0,0,640,400,2,4,winidcmp,winflags,wintitle,scr,0,0,0) 
  27. rpw1 = getwindowrastport(w1) 
  28.  
  29. menustrip1 = makemenu(w1,"PICK ONE OF THESE",0,0,MENUENABLED,0)
  30.  
  31.   m0 = makeitem(w1,"UGLY SYSTEM REQUESTER",menustrip1,0,4,0,0,0,0,'A',6,3,JAM1,0,0)
  32.   m1 = makeitem(w1,"MY LITTLE REQUESTER  ",menustrip1,0,40,0,0,0,0,'A',6,3,JAM1,0,0)
  33.  
  34. call setmenustrip(w1,menustrip1)
  35.  
  36. menuitem0 = menunumber(menustrip1,menustrip1,m0,0)
  37. menuitem1 = menunumber(menustrip1,menustrip1,m1,0)
  38.  
  39.  
  40. /* My Little Requester */
  41.  
  42. g1 = makestrgadget(w1,20,50,320,11,GADGHCOMP,RELVERIFY+ENDGADGET,0,5,0,0,22,0,100)
  43. z  = setstrgad(g1,"Enter Something into this gadget")
  44.  
  45. gix  = makeitext(w1,"END REQ",AUTOLEFTEDGE,AUTOTOPEDGE,0,3,JAM2,0,0)
  46. gix1 = makeitext(w1,"THIS GADGET ENDS THE REQUEST",90,AUTOTOPEDGE,5,1,JAM2,0,gix)
  47. g2   = makeboolgadget(w1,10,90,67,12,GADGHCOMP,GADGIMMEDIATE+ENDGADGET,gix,5,0,0,26,g1)
  48.  
  49. giy  = makeitext(w1,"WON'T END IT",AUTOLEFTEDGE,AUTOTOPEDGE,1,5,JAM2,0,0)
  50. giy1 = makeitext(w1,"THIS GADGET DOES NOT END THE REQUEST",120,AUTOTOPEDGE,4,2,JAM2,0,giy)
  51. g3   = makeboolgadget(w1,10,110,106,12,GADGHCOMP,GADGIMMEDIATE,giy,5,0,0,27,g1)
  52.  
  53. giz  = makeitext(w1,"WILL FORCE ENDREQ",AUTOLEFTEDGE,AUTOTOPEDGE,0,3,JAM2,0,0)
  54. giz1 = makeitext(w1,"THIS GADGET CALLS ENDREQUEST() ",160,AUTOTOPEDGE,7,3,JAM2,0,giz)
  55. g4   = makeboolgadget(w1,10,130,145,12,GADGHCOMP,GADGIMMEDIATE,giz,5,0,0,28,g1)
  56.  
  57. /* the left & top edge of the itext is relative to the requester */
  58. i1x = makeitext(w1,"This is Your Requester Buddy",10,10,3,2,JAM2,0,0)
  59.  
  60. /* itext below gets linked to the one above */
  61. call makeitext(w1," The String Gadget Above Ends the Requester",20,70,3,2,JAM2,0,i1x)
  62.  
  63. req  = makerequester(w1,20,20,450,150,g1,i1x,0,4,0,0,0,0)
  64.  
  65.  
  66.  
  67. /* DMRequester */
  68. reqbitmap = loadiff("req6bitmap",w1)
  69. reqwidth  = iffwidth(reqbitmap)
  70. reqheight = iffheight(reqbitmap)
  71. req2g1 = makeboolgadget(w1,0,0,reqwidth,reqheight,GADGHCOMP,GADGIMMEDIATE+ENDGADGET,0,5,0,0,128,0)
  72. req2 = makerequester(w1,0,0,reqwidth,reqheight,req2g1,0,0,6,POINTREL+PREDRAWN,0,0,reqbitmap)
  73. call makeitext(w1,"This is Your Requester Buddy",10,10,1,2,JAM2,0,req2)
  74. x = setdmrequest(w1,req2)
  75.  
  76.  
  77.  
  78. /* --- auto request text --- */
  79.  
  80. bodytext = makeitext(w1,"This is Your Requester Buddy",10,10,1,5,JAM2,0,0)
  81. call makeitext(w1," Use one of the gadgets below ",10,21,1,5,JAM2,0,bodytext)
  82. call makeitext(w1,"   to end this requester",10,32,1,5,JAM2,0,bodytext)
  83. yestext = makeitext(w1," YES ",AUTOLEFTEDGE,AUTOTOPEDGE,AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,0,0)
  84. notext  = makeitext(w1," NO ",AUTOLEFTEDGE,AUTOTOPEDGE,AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,0,0)
  85.  
  86.  
  87. z = pitext(rpw1,50,50,"This is an example of using requesters",5,2,JAM2,0)
  88. z = pitext(rpw1,50,80,"  select a Requester from the MENU",5,2,JAM2,0)
  89. z = pitext(rpw1,50,110,"  ... or you can double-click the mouse Menu-Button",5,2,JAM2,0)
  90.  
  91. exitme = 0
  92. do forever
  93.      x = waitpkt(portname)
  94.   
  95.      do forever 
  96.   
  97.         msg = '0000 0000'x
  98.         msg = getpkt(portname)
  99.         if msg = '0000 0000'x then leave
  100.         class = getarg(msg,0)
  101.         if class = CLOSEWINDOW then exitme = 1
  102.         if class = MENUPICK then 
  103.           do
  104.              menselect = getarg(msg,1)
  105.              x = reply(msg,0)  
  106.              if menselect = menuitem1 then 
  107.                 do
  108.                    Y = request(req,w1)  
  109.                    if Y = 1 then call getreqresponse()
  110.                 end
  111.              else   
  112.              if menselect = menuitem0 then 
  113.                 do
  114.                    Y = autorequest(w1,bodytext,yestext,notext,0,0,450,100)
  115.                 end
  116.           end
  117.         else  
  118.            x = reply(msg,0)  
  119.      end  
  120.    if exitme = 1 then leave
  121.    
  122. end
  123.  
  124. x = cleardmrequest(w1)
  125. /* a = freemenu(menustrip1) */
  126. a = closewindow(w1)
  127. a = closescreen(scr)
  128.  
  129. exit
  130.  
  131. /* ----------------------------------------------------------------------- 
  132.    get intui-message from requester 
  133.    ----------------------------------------------------------------------- */
  134.  
  135. getreqresponse:
  136.  reqexit = 0
  137.  do forever
  138.      if reqexit ~= 0 then leave
  139.      x = waitpkt(portname)
  140.      do forever
  141.         msg = getpkt(portname)
  142.         if msg = '0000 0000'x then leave
  143.         class = getarg(msg,0)
  144.         if class = REQCLEAR then reqexit = 1
  145.         if class = GADGETDOWN then 
  146.            do
  147.                if getarg(msg,9) = 28 then /* if gadid=28 force endrequest */
  148.                do
  149.                   say "Gagdet ID = " getarg(msg,9) "Forcing ENDREQUEST() "
  150.                   reqexit = endrequest(req,w1)
  151.                   end
  152.            end
  153.         rr = Reply(msg,0)   
  154.      end
  155.  end
  156. return 1
  157.